﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="StuffManageView.aspx.cs" Inherits="StuffManageView" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>
        <%=System.Configuration.ConfigurationManager.AppSettings["SYSTitle"]%></title>
       <link href="../Style/Style.css" type="text/css" rel="STYLESHEET">
       <link href="../Controls/easyui/themes/icon.css" rel="stylesheet" type="text/css" />
        <link href="../Controls/easyui/themes/gray/easyui.css" rel="stylesheet" type="text/css" />
        <script src="../Controls/easyui/jquery.min.js" type="text/javascript"></script>
        <script src="../Controls/easyui/jquery.easyui.min.js" type="text/javascript"></script>

    <script type="text/javascript" language="javascript">

        $(function () {

            var strType = GetQueryString("type");
            if (strType == "jihua") {
                //$("#blockdiv").
                $("#stuffListFrame").attr('src', './StuffList.aspx?planId=<%=planID %>');
            }
            else if (strType == "fenxi") {
                $("#stuffListFrame").attr('src', './StuffListVerify.aspx?planId=<%=planID %>');
            }
            else if (strType == "huafen") {
                $("#stuffListFrame").attr('src', './StuffListDevide.aspx?planId=<%=planID %>');
            }
            else if (strType == "shenhe") {
                $("#stuffListFrame").attr('src', './StuffListVerifyPrice.aspx?planId=<%=planID %>');
            }


            if (GetQueryString("DoType") == "edit") {
                
                if (strType == "jihua") {
                    //$("#blockdiv").
                    $("#panel").css("display", "block");
                }
                else if (strType == "fenxi" || strType == "shenhe") {
                    $("#fx_panel").css("display", "block");
                }
                else if (strType == "huafen") {
                    $("#hf_panel").css("display", "block");
                }
            }

        });

        var idForChange = null;

        function initEditpanel(name, unit, number, price, tecPara, id) {
            $("#stuffName").val(name);
            $("#JiLiangUnit").val(unit);
            $("#PlanNumber").val(number);
            $("#GaiSuanPrice").val(price);
            $("#JiShuCanSHu").val(tecPara);
            idForChange = id;
        }

        $(function () {
            //alert(GetQueryString("ID"));


            //修改
            $("#btnEdit").click(function () {

                if ($("#stuffName").val() == "" || $("#PlanNumber").val() == "") {
                    alert("数据参数不全");
                    return;
                }
                if (idForChange == null) {
                    alert("请重新选择修改项");
                    return;
                }

                $.ajax({ url: "./StuffManageView.aspx",
                    data: {
                        fun: "edit",
                        name: escape($("#stuffName").val()),
                        unit: escape($("#JiLiangUnit").val()),
                        number: $("#PlanNumber").val(),
                        price: $("#GaiSuanPrice").val(),
                        tecPara: "",
                        ID: idForChange
                    },
                    type: 'post',
                    success: function (data) {
                        if (data == "success") {
                            $('#stuffListFrame').attr('src', $('#stuffListFrame').attr('src'));
                        } else if (data == "error") {
                            alert("添加出错了，请联系管理员");
                        }
                    }
                });
            });


            //提交
            $("#btnSave").click(function () {
                if (!confirm("提交后数据将不能修改，确定提交吗?")) {
                    return;
                }
                $.ajax({ url: "./StuffManageView.aspx",
                    data: {
                        fun: "save",
                        planId: GetQueryString("ID")
                    },
                    type: 'post',
                    success: function (data) {
                        if (data == "success") {
                            alert("提交成功");
                            //   $('#stuffListFrame').attr('src', $('#stuffListFrame').attr('src'));
                        } else if (data == "error") {
                            alert("提交出错了，请联系管理员");
                        }
                    }
                });
            });
            //分析提交 
            $("#fxSave").click(function () {

                if (!confirm("提交后数据将不能修改，确定提交吗?")) {
                    return;
                }
                $.ajax({ url: "./StuffManageView.aspx",
                    data: {
                        fun: "fxSave",
                        planId: GetQueryString("ID")
                    },
                    type: 'post',
                    success: function (data) {
                        if (data == "success") {
                            alert("提交成功");
                            // $('#stuffListFrame').attr('src', $('#stuffListFrame').attr('src'));
                        } else if (data == "error") {
                            alert("提交出错了，请联系管理员");
                        }
                    }
                });
            });

            //物资划分提交 
            $("#devide_save").click(function () {

                if (!confirm("提交后数据将不能修改，确定提交吗?")) {
                    return;
                }
                $.ajax({ url: "./StuffManageView.aspx",
                    data: {
                        fun: "devide_save",
                        planId: GetQueryString("ID")
                    },
                    type: 'post',
                    success: function (data) {
                        if (data == "success") {
                            alert("划分成功");
                            // $('#stuffListFrame').attr('src', $('#stuffListFrame').attr('src'));
                        } else if (data == "error") {
                            alert("提交出错了，请联系管理员");
                        }
                    }
                });


            });


            //分析驳回
            $("#fxReject").click(function () {
                if (!confirm("提交后数据将不能修改，确定提交吗?")) {
                    return;
                }
                $.ajax({ url: "./StuffManageView.aspx",
                    data: {
                        fun: "fxReject",
                        planId: GetQueryString("ID")
                    },
                    type: 'post',
                    success: function (data) {
                        if (data == "success") {
                            alert("驳回成功")
                            // $('#stuffListFrame').attr('src', $('#stuffListFrame').attr('src'));
                        } else if (data == "error") {
                            alert("提交出错了，请联系管理员");
                        }
                    }
                });

            });

            //添加
            $("#btnAdd").click(function () {

                idForChange = null;
                if ($("#stuffName").val() == "" || $("#PlanNumber").val() == "") {
                    alert("数据参数不全");
                    return;
                }

                $.ajax({ url: "./StuffManageView.aspx",
                    data: {
                        fun: "add",
                        name: escape($("#stuffName").val()),
                        unit: escape($("#JiLiangUnit").val()),
                        number: $("#PlanNumber").val(),
                        price: $("#GaiSuanPrice").val(),
                        tecPara: "",
                        planId: GetQueryString("ID")
                    },
                    type: 'post',
                    success: function (data) {
                        if (data == "success") {
                            $('#stuffListFrame').attr('src', $('#stuffListFrame').attr('src'));
                        } else if (data == "error") {
                            alert("添加出错了，请联系管理员");
                        }

                    }
                });
            });
        });

        function PrintTable() {
            document.getElementById("PrintHide").style.visibility = "hidden"
            print();
            document.getElementById("PrintHide").style.visibility = "visible"
        }
        function DownloadFile(FileURL)   //下载附件
        {
            document.getElementById("hdnFileURL").value = FileURL;
            document.getElementById("btnDownloadFile").click();
        }
        function GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <input id="hdnFileURL" runat="server" type="hidden" />
    <div style="width: 0px; height: 0px; display: none;">
        <asp:Button ID="btnDownloadFile" Width="0px" Height="0px" runat="server" Text="Button"
            OnClick="btnDownloadFile_Click" />
    </div>
    <div>
    

       <table id="PrintHide" style="width: 100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td valign="middle" style="border-bottom: #006633 1px dashed; height: 30px;">
                    &nbsp;<img src="../images/BanKuaiJianTou.gif" />
                    <a class="hei" href="../Main/MyDesk.aspx">桌面</a>&nbsp;>>&nbsp;采购订单&nbsp;>>&nbsp;查看采购订单信息
                </td>
                <td align="right" valign="middle" style="border-bottom: #006633 1px dashed; height: 30px;">
               <%--  <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/Button/Submit.jpg"
                        OnClick="ImageButton1_Click" />--%>
                    <img src="../images/Button/JianGe.jpg" />&nbsp;
                    <img class="HerCss" onclick="PrintTable()" src="../images/Button/BtnPrint.jpg" />
                    <img src="../images/Button/JianGe.jpg" />&nbsp;
                    <img class="HerCss" onclick="javascript:window.history.go(-1)" src="../images/Button/BtnExit.jpg" />&nbsp;
                </td>
            </tr>
            <tr>
                <td height="3px" colspan="2" style="background-color: #ffffff">
                </td>
            </tr>
        </table>

        <div id="panel" style="display:none">
       <table style="width: 100%" bgcolor="#999999" border="0" cellpadding="2" cellspacing="1">
	<tr>
	<td style="width: 170px; height: 25px; background-color: #D6E2F3" align="right">
		物资名称及规格型号：
	</td>
	<td style="padding-left: 5px; height: 25px; background-color: #ffffff" >
		<asp:TextBox id="stuffName" runat="server" Width="350px"></asp:TextBox>
		<img class="HerCss" onclick="var wName;var RadNum=Math.random();wName=window.showModalDialog('../Main/SelectCondition.aspx?TableName=ERPBuyOrder&LieName=OrderName&Radstr='+RadNum,'','dialogWidth:350px;DialogHeight=400px;status:no;help:no;resizable:yes;');if(wName==null){}else{document.getElementById('txtOrderName').value=wName;}"  src="../images/Button/search.gif" />
		<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="stuffName" ErrorMessage="*该项不可以为空"></asp:RequiredFieldValidator>
	</td></tr>
	<tr>
	<td style="width: 170px; height: 25px; background-color: #D6E2F3" align="right">
		计量单位：
	</td>
	<td style="padding-left: 5px; height: 25px; background-color: #ffffff" >
		<asp:TextBox id="JiLiangUnit" runat="server" Width="350px" 
            ></asp:TextBox>
		<img class="HerCss" onclick="var wName;var RadNum=Math.random();wName=window.showModalDialog('../Main/SelectCondition.aspx?TableName=ERPProduct&LieName=ProductName&Radstr='+RadNum,'','dialogWidth:350px;DialogHeight=400px;status:no;help:no;resizable:yes;');if(wName==null){}else{document.getElementById('txtProductName').value=wName;__doPostBack('', '');}"  src="../images/Button/search.gif" />
        </td></tr>
	<tr>
	<td style="width: 170px; height: 25px; background-color: #D6E2F3" align="right">
		计划数量：
	</td>
	<td style="padding-left: 5px; height: 25px; background-color: #ffffff" >
		<asp:TextBox id="PlanNumber" runat="server" Width="350px"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="PlanNumber"
            ErrorMessage="*该项不可以为空"></asp:RequiredFieldValidator>
		<img class="HerCss" onclick="var wName;var RadNum=Math.random();wName=window.showModalDialog('../Main/SelectCondition.aspx?TableName=ERPProduct&LieName=ProductSerils&Radstr='+RadNum,'','dialogWidth:350px;DialogHeight=400px;status:no;help:no;resizable:yes;');if(wName==null){}else{document.getElementById('txtProductSerils').value=wName;}"  src="../images/Button/search.gif" />
	</td></tr>
	<tr>
	<td style="width: 170px; height: 25px; background-color: #D6E2F3" align="right">
		概算价：
	</td>
	<td style="padding-left: 5px; height: 25px; background-color: #ffffff" >
		<asp:TextBox id="GaiSuanPrice" runat="server" Width="350px"></asp:TextBox>
		<img class="HerCss" onclick="var wName;var RadNum=Math.random();wName=window.showModalDialog('../Main/SelectCondition.aspx?TableName=ERPSupplys&LieName=SupplysName&Radstr='+RadNum,'','dialogWidth:350px;DialogHeight=400px;status:no;help:no;resizable:yes;');if(wName==null){}else{document.getElementById('txtGongYingShang').value=wName;}"  src="../images/Button/search.gif" />
	</td></tr>
	
	


    <tr>
	<td style="width: 170px; height: 25px; background-color: #D6E2F3" align="right">
		
	</td>
	<td style="padding-left: 5px; height: 25px; background-color: #ffffff" >
		 <a href="#"  id="btnAdd"  class="easyui-linkbutton" data-options="iconCls:'icon-add'">添加</a>
        <a href="#"  id="btnEdit" class="easyui-linkbutton" data-options="iconCls:'icon-edit'">编辑</a>
        <a href="#" id="btnSave" class="easyui-linkbutton" data-options="iconCls:'icon-save'">提交</a>
     
	</td></tr>

        </table>
       
       </div>

<div id="fx_panel"  style="display:none"   >

       <table id="Table1" style="width: 100%" bgcolor="#999999" border="0" cellpadding="2" cellspacing="1">
          
	<tr>
            <td align="right" style="width: 170px; height: 25px; background-color: #D6E2F3">
                审批意见：</td>
            <td style="padding-left: 5px; height: 25px; background-color: #ffffff">
                <asp:TextBox ID="TextBox1" runat="server" Height="100px" TextMode="MultiLine" Width="350px"></asp:TextBox><br /></td>
        </tr>
	
	
	


    <tr>
	<td style="width: 170px; height: 25px; background-color: #D6E2F3" align="right">
		
	</td>
	<td style="padding-left: 5px; padding-top:3px; height: 30px; background-color: #ffffff" >
		 <a href="#"  id="fxSave"  class="easyui-linkbutton" data-options="iconCls:'icon-save'">通过并提交</a>
        <a href="#"  id="fxReject" class="easyui-linkbutton" data-options="iconCls:'icon-redo'">提交并驳回到发文人</a>
      
	</td></tr>

        </table>
       
       </div>
   
<div id="hf_panel" style="display:none" >

       <table id="Table2" style="width: 100%" bgcolor="#999999" border="0" cellpadding="2" cellspacing="1">

    <tr>
	<td style="width: 170px; height: 25px; background-color: #D6E2F3" align="right">
		
	</td>
	<td style="padding-left: 5px; padding-top:3px; height: 30px; background-color: #ffffff" >
		 <a href="#"  id="devide_save"  class="easyui-linkbutton" data-options="iconCls:'icon-save'">提交到物资审核</a>
	</td></tr>

        </table>
       
       </div>


        <hr style="height: 1px; color: #003333;">
        &nbsp;&nbsp;
        <img src="../images/TreeImages/hrms.gif" /><a target="RMid" href="StuffManageView.aspx?OrderName=<%=OrderName %>">订单产品记录</a>&nbsp;&nbsp;
        <hr style="height: 1px; color: #003333;">
        <iframe id="stuffListFrame" name="RMid" frameborder="0" marginheight="0" marginwidth="0" width="100%"
            height="500" bordercolor="#ffffFF" src=""
            border="0"></iframe>
    </div>
    </form>
</body>
</html>
